package jiyici;

import handler.DataInvalidException;

import java.util.ArrayList;

import org.codehaus.jackson.JsonNode;

public class Client2ServerSyncData {
    
    private ArrayList<Client2ServerSyncItem> items;
    
    public ArrayList<Client2ServerSyncItem> getItems() {
        return items;
    }
    
    public void fromJson(JsonNode json) throws DataInvalidException {
        if (json == null || !json.isArray()) {
            throw new DataInvalidException();
        }
        int size = json.size();
        items = new ArrayList<Client2ServerSyncItem>(size + 1);
        for (int i = 0; i < size; i++) {
            JsonNode itemNode = json.get(i);
            Client2ServerSyncItem item = new Client2ServerSyncItem();
            item.fromJson(itemNode);
            items.add(item);
        }
    }

}
